package jiachunlei.factory.lesson1;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/12/1 19:30
 */
public class OperatorFactory
{
    public static Operator<Integer> createOperator(String name){
        Operator<Integer> operator;
        switch (name){
            case "+":
                operator = new AddOperator();
                break;
            case "*":
                operator = new MultiOperator();
                break;
            default:
                throw new RuntimeException("Wrong Operator Name: " + name);
        }
        return operator;
    }
}
